import React, { Component } from 'react';
import { Layout, Menu, Icon } from 'antd';

import { Link } from 'react-router-dom';

import logo from '../logo.svg';
import '../App.css';

const { Sider } = Layout;
const SubMenu = Menu.SubMenu;


class SilderMain extends Component {
  state = {
    name: 'silderMain',
    openKey: '',
    selectedKey: ''
  };
  componentDidMount() {

  }
  componentWillReceiveProps() {

  }

  menuClick = e => {
    console.log(e);
    this.setState({
      selectedKey: e.key
    });
    // console.log(this.state);
    // const { popoverHide } = this.props;     
    // 响应式布局控制小屏幕点击菜单时隐藏菜单操作
    // popoverHide && popoverHide();
  };
  openMenu = v => {
    // console.log(v);
    this.setState({
      openKey: v[v.length - 1]
    })
  };
  render() {
    return (
      // position: 'fixed'  boxSizing: 'border-box'
      <Sider width={200} style={{ background: '#fff', height: '100%', }}>
        <div>
          <img src={logo} className="App-logo" alt="logo" />
        </div>
        <Menu
          onClick={this.menuClick}
          mode="inline"
          selectedKeys={[this.state.selectedKey]}
          openKeys={[this.state.openKey]}
          onOpenChange={this.openMenu}
          defaultSelectedKeys={['1']}
          defaultOpenKeys={['sub1']}
          style={{ height: 'auto' }}
        >
          <SubMenu key="sub1" title={<span><Icon type="user" />subnav 1</span>}>
            <Menu.Item key="/app/swiper"><Link to={'/app/swiper'}>轮播</Link></Menu.Item>
            <Menu.Item key="/app/echart"><Link to={'/app/echart'}>图表</Link></Menu.Item>
            <Menu.Item key="/app/select"><Link to={'/app/select'}>传值</Link></Menu.Item>
            <Menu.Item key="/app/redux"><Link to={'/app/redux'}>redux</Link></Menu.Item>
          </SubMenu>
          <SubMenu key="sub2" title={<span><Icon type="laptop" />subnav 2</span>}>
            <Menu.Item key="/app/http"><Link to={'/app/http'}>http</Link></Menu.Item>
            <Menu.Item key="6">option6</Menu.Item>
            <Menu.Item key="7">option7</Menu.Item>
            <Menu.Item key="8">option8</Menu.Item>
          </SubMenu>
          <SubMenu key="sub3" title={<span><Icon type="notification" />subnav 3</span>}>
            <Menu.Item key="9">option9</Menu.Item>
            <Menu.Item key="10">option10</Menu.Item>
            <Menu.Item key="11">option11</Menu.Item>
            <Menu.Item key="12">option12</Menu.Item>
          </SubMenu>
        </Menu>

      </Sider>
    )
  }
}

export default SilderMain;